package org.example.new_hbps_backend_reconstruction.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.new_hbps_backend_reconstruction.entity.SleepLogsEntity;

import java.time.LocalDateTime;

/**
 * @author 丁利军
 * @date 2025年10月15日 21:08
 * @description
 */
// SleepLogsMapper.java
@Mapper
public interface SleepLogsMapper extends BaseMapper<SleepLogsEntity> {

    SleepSummary sumSleepByDate(@Param("patientUid") Long patientUid,
                                @Param("startTime") LocalDateTime startTime,
                                @Param("endTime") LocalDateTime endTime);

    /** 封装查询结果的内部类 */
    class SleepSummary {
        private Integer lightMinutes;
        private Integer deepMinutes;

        public Integer getLightMinutes() {
            return lightMinutes == null ? 0 : lightMinutes;
        }

        public void setLightMinutes(Integer lightMinutes) {
            this.lightMinutes = lightMinutes;
        }

        public Integer getDeepMinutes() {
            return deepMinutes == null ? 0 : deepMinutes;
        }

        public void setDeepMinutes(Integer deepMinutes) {
            this.deepMinutes = deepMinutes;
        }
    }
}
